Drop parent->realized => child->realized invariant
authorAlexander Larsson <alexl@redhat.com>
Tue, 28 Apr 2020 12:32:57 +0000 (14:32 +0200)
committerAlexander Larsson <alexl@redhat.com>
Tue, 28 Apr 2020 12:32:57 +0000 (14:32 +0200)
We already dropped this invariant in gtk_widget_verify_invariants()
because it was not true in all cases. Also, it is not really useful
these days as we extended what it means to be a "child" to also
include widgets in different toplevels.

For example, a popup in a popup button need not be realized just
because the button is in a realized window. The main invariants
we want are:

 * Parent is realized before child
 * Widget is realized before it is mapped

This sounds like its not a huge deal, but in fact it is a massive win
for things like menus, because when we go between menus in a menubar
each switch between two open menus involves a lot of intermingled
crossing events to different surfaces and for each of these the
tooltip window of the toplevel gets assigned to the new surface.  This
shouldn't be a huge deal, as the tooltip window is not even visible,
but due to the realized invariant it get re-realized each time it gets
re-assigned.

gtk/gtkwidget.c

index cf5499b8d41dc5c5d4e22fb8a6df885b75a391f7..386d39721897555631f3cdbd578842d545b64967 100644 (file)
@@ -5901,11 +5901,7 @@ gtk_widget_reposition_after (GtkWidget *widget,
   if (prev_parent == NULL)
     g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_PARENT]);
 
-  /* Enforce realized/mapped invariants
-   */
-  if (_gtk_widget_get_realized (priv->parent))
-    gtk_widget_realize (widget);
-
+  /* Enforce mapped invariants */
   if (_gtk_widget_get_visible (priv->parent) &&
       _gtk_widget_get_visible (widget))
     {